define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'mall.promotion/index',
        confirm_url: 'mall.promotion/confirm',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar: ['refresh',
                ],
                cols: [[
                    {type: 'checkbox'},
                    {field: 'name', title: '姓名'},
                    {field: 'mobile', title: '手机号'},
                    {field: 'id_number', title: '身份证号', search: false},
                    {field: 'count', title: '推广人数', search: false},
                    {field: 'order_num', title: '订单数量', search: false},
                    {field: 'order_price', title: '订单金额', templet: ea.table.price, search: false},
                    {field: 'amount', title: '积分', search: false},
                    {field: 'status', title: '状态', selectList: {0: '未开通', 1: '已开通'},},
                    {field: 'promotion_time', title: '开通时间', search: false},
                    {
                        width: 250, title: '操作', templet: function (row) {
                            var operat = []
                            var status = row.status
                            if (status === 0) {
                                operat.push(
                                    [
                                        {
                                            class: 'layui-btn layui-btn layui-btn-xs',
                                            method: 'get',
                                            field: 'id',
                                            icon: '',
                                            text: '确认开通',
                                            title: '确认开通？',
                                            auth: 'confirm',
                                            url: init.confirm_url,
                                            extend: ""
                                        }
                                    ]
                                )
                            }

                            return ea.table.tool(row, {
                                init, // 初始化的数据变量
                                operat: operat
                            }); // 其他状态下 没有操作按钮返回空字符串即可
                        }
                    },
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});